<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description">
<meta property="og:type" content="website">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hexo">
<meta name="twitter:description">
  
    <link rel="alternative" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css" type="text/css">
  

</head>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-资料" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/30/资料/" class="article-date">
  <time datetime="2016-01-29T17:47:36.000Z" itemprop="datePublished">2016-01-30</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>beanstalkd：<a href="https://raw.github.com/kr/beanstalkd/master/doc/protocol.txt" target="_blank" rel="external">https://raw.github.com/kr/beanstalkd/master/doc/protocol.txt</a> </p>
<p>ZeroMQ、ActiveMQ、Kafka、HornetQ、Apache Qpid、Sparrow、Starling、Kestrel、Beanstalkd、Amazon SQS</p>
<p>TinyOWS：<a href="http://live.osgeo.org/zh/quickstart/tinyows_quickstart.html" target="_blank" rel="external">http://live.osgeo.org/zh/quickstart/tinyows_quickstart.html</a></p>
<p><a href="http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames" target="_blank" rel="external">http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames</a></p>
<p>Netty系列之Netty百万级推送服务设计要点：<br><a href="http://www.infoq.com/cn/articles/netty-million-level-push-service-design-points/" target="_blank" rel="external">http://www.infoq.com/cn/articles/netty-million-level-push-service-design-points/</a></p>
<h2 id="u811A_u672C_u538B_u7F29"><a href="#u811A_u672C_u538B_u7F29" class="headerlink" title="脚本压缩"></a>脚本压缩</h2><p>　　1. 采用notepad++的插件JSTool进行单个大JS脚本的文件<br>　　2. 雅虎的Yui Compressor，与Ant配合使用(支持CSS，JS等)<a href="/code/build.xml">build.xml</a>，<a href="/code/yuicompressor-2.4.6.jar">yuicompressor-2.4.6.jar</a><br>　　3. Closure Compiler：好像只支持jdk7<br>　　4. nodejs插件：uglifyjs<br>　　5. 浏览器插件</p>
<p>简要介绍</p>
<p>RabbitMQ</p>
<p>RabbitMQ是实现AMQP（高级消息队列协议）的消息中间件的一种，最初起源于金融系统，用于在分布式系统中存储转发消息，在易用性、扩展性、高可用性等方面表现不俗。消息中间件主要用于组件之间的解耦，消息的发送者无需知道消息使用者的存在，反之亦然。<br>Redis</p>
<p>是一个Key-Value的NoSQL数据库，开发维护很活跃，虽然它是一个Key-Value数据库存储系统，但它本身支持MQ功能，所以完全可以当做一个轻量级的队列服务来使用。<br>具体对比</p>
<p>可靠消费</p>
<p>Redis：没有相应的机制保证消息的消费，当消费者消费失败的时候，消息体丢失，需要手动处理。即一旦订阅者断线，将无法接收到消息，再次连接上之后，在断线期间发布的消息都是无法获取到的。只能采用list数组实现，采用rpush/lpop组合命令来实现先进先出的队列模型（在代码中while(true)循环体内执行blpop/brpop方法，则可以间接实现消息队列模型），当然redis也提供了阻塞版本的blpush/brpush/blpop/brpop等，就看我们实际环境下如何使用了。在实际的使用中，采用jedis的客户端，实现消息队列，消费者上线后是无法获取到断线期间发布的消息的。</p>
<p>RabbitMQ：具有消息消费确认，即使消费者消费失败，也会自动使消息体返回原队列，同时可全程持久化，保证消息体被正确消费<br>可靠发布</p>
<p>Reids：不提供，需自行实现<br>RabbitMQ：具有发布确认功能，保证消息被发布到服务器<br>高可用</p>
<p>Redis：采用主从模式，读写分离，但是故障转移还没有非常完善的官方解决方案<br>RabbitMQ：集群采用磁盘、内存节点，任意单点故障都不会影响整个队列的操作<br>持久化</p>
<p>Redis：将整个Redis实例持久化到磁盘<br>RabbitMQ：队列，消息，都可以选择是否持久化<br>消费者负载均衡</p>
<p>Redis：不提供，需自行实现<br>RabbitMQ：根据消费者情况，进行消息的均衡分发<br>队列监控</p>
<p>Redis：不提供，需自行实现<br>RabbitMQ：后台可以监控某个队列的所有信息，（内存，磁盘，消费者，生产者，速率等）<br>流量控制</p>
<p>Redis：不提供，需自行实现<br>RabbitMQ：服务器过载的情况，对生产者速率会进行限制，保证服务可靠性<br>出入队性能</p>
<p>对于RabbitMQ和Redis的入队和出队操作，各执行100万次，每10万次记录一次执行时间。<br>测试数据分为128Bytes、512Bytes、1K和10K四个不同大小的数据。<br>实验表明：<br>入队时，当数据比较小时Redis的性能要高于RabbitMQ，而如果数据大小超过了10K，Redis则慢的无法忍受；<br>出队时，无论数据大小，Redis都表现出非常好的性能，而RabbitMQ的出队性能则远低于Redis。<br>应用场景分析</p>
<p>Redis：轻量级，高并发，延迟敏感 即时数据分析、秒杀计数器、缓存等<br>RabbitMQ：重量级，高并发，异步 批量数据异步处理、并行任务串行化，高负载任务的负载均衡等</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/30/资料/" data-id="cijzzpv0b00081cfsjbsrgvv5" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-java/13.Classloader系列一" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/30/java/13.Classloader系列一/" class="article-date">
  <time datetime="2016-01-29T17:47:36.000Z" itemprop="datePublished">2016-01-30</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/java/">java</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/30/java/13.Classloader系列一/">ClassLoader系列一</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="JDK_u9ED8_u8BA4ClassLoader"><a href="#JDK_u9ED8_u8BA4ClassLoader" class="headerlink" title="JDK默认ClassLoader"></a>JDK默认ClassLoader</h3><p>　　SPI的全名为Service Provider Interface，究其思想，其实是和回调差不多。回调的思想是在我们调用API的时候，可以自己写一段逻辑代码，传入到API里面，API内部在合适的时候会调用它，从而实现某种程度的定制。 </p>
<p>　　我们系统里抽象的各个模块，往往有很多不同的实现方案，比如日志模块的方案，xml解析模块等。面向的对象的设计里，我们一般推荐模块之间基于接口编程，模块之间不对实现类进行硬编码。一旦代码里涉及具体的实现类，就违反了可拔插的原则，如果需要替换一种实现，就需要修改代码。</p>
<p>　　为了实现在模块装配的时候能不在程序里动态指明，这就需要一种服务发现机制spi：为某个接口寻找服务实现的机制。有点类似IOC的思想，就是将装配的控制权移到程序之外，在模块化设计中这个机制尤其重要。</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/30/java/13.Classloader系列一/" data-id="cijzzpvee00do1cfszy9msdjb" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/classloader/">classloader</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-hadoop/1.hadoop系列之源码编译" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/29/hadoop/1.hadoop系列之源码编译/" class="article-date">
  <time datetime="2016-01-29T09:08:00.000Z" itemprop="datePublished">2016-01-29</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/hadoop/">hadoop</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/29/hadoop/1.hadoop系列之源码编译/">hadoop系列一之源码编译</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="u7B80_u4ECB"><a href="#u7B80_u4ECB" class="headerlink" title="简介"></a>简介</h2><p>　　1. 安装JDK，并添加环境变量<br>　　2. 安装maven，并添加环境变量，切记将settings.xml调整为maven私服地址<br>　　3. 安装findbugs，并添加环境变量<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># findbugs是用于生成文档的。如果不需要编译生成文档，可以不执行该步骤。</span></span><br><span class="line"><span class="comment"># findbugs地址是http://sourceforge.jp/projects/sfnet_findbugs/releases/，选择findbugs-3.0.0-dev-20131204-e3cbbd5.tar.gz下载。</span></span><br><span class="line">tar -zxvf  findbugs-<span class="number">3.0</span>.<span class="number">0</span>-dev-<span class="number">20131204</span><span class="operator">-e</span>3cbbd5.tar.gz</span><br><span class="line"><span class="built_in">source</span>  /etc/profile</span><br><span class="line">findbugs -version</span><br></pre></td></tr></table></figure></p>
<p>　　4. 安装protoc，需要先编译protoc，再添加环境变量<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">yum install gcc (centos <span class="number">6.5</span>已安装)</span><br><span class="line">yum install gcc-c++</span><br><span class="line">yum install make (centos <span class="number">6.5</span>已安装)</span><br><span class="line"><span class="built_in">cd</span> protobuf-<span class="number">2.5</span>.<span class="number">0</span></span><br><span class="line">./configure --prefix=/usr/<span class="built_in">local</span>/protoc</span><br><span class="line">make &amp;&amp; make install</span><br><span class="line">protoc --version</span><br></pre></td></tr></table></figure></p>
<p>　　5. 安装其他依赖<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">yum install cmake  </span><br><span class="line">yum install openssl-devel  </span><br><span class="line">yum install ncurses-devel</span><br></pre></td></tr></table></figure></p>
<p>　　6. 源代码中有个bug，编辑目录hadoop-2.2.0-src/hadoop-common-project/hadoop-auth中的文件pom.xml，添加依赖<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="title">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="title">groupId</span>&gt;</span>org.mortbay.jetty<span class="tag">&lt;/<span class="title">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="title">artifactId</span>&gt;</span>jetty-util<span class="tag">&lt;/<span class="title">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="title">scope</span>&gt;</span>test<span class="tag">&lt;/<span class="title">scope</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="title">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>　　上述bug详见<a href="https://issues.apache.org/jira/browse/HADOOP-10110" target="_blank" rel="external">https://issues.apache.org/jira/browse/HADOOP-10110</a>，进入到目录/usr/local/hadoop-2.2.0-src中，执行命令：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mvn package -DskipTests -Pdist,native,docs</span><br></pre></td></tr></table></figure></p>
<p>　　编译后的代码在hadoop-2.2.0-src/hadoop-dist/target下面，切记：以上的软件都安装在/usr/local目录下，如果将hadoop的源码解压到桌面，且此时是以hadoop用户而非root用户登录时，运行mvn package -DskipTests -Pdist,native,docs会提示maven插件的问题，很奇怪。</p>
<h2 id="u53C2_u8003_u8D44_u6599"><a href="#u53C2_u8003_u8D44_u6599" class="headerlink" title="参考资料"></a>参考资料</h2><p><a href="http://www.superwu.cn/2013/12/26/913/" target="_blank" rel="external">http://www.superwu.cn/2013/12/26/913/</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/29/hadoop/1.hadoop系列之源码编译/" data-id="cijzzpvez00ea1cfs8jy5pv7r" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/hadoop/">hadoop</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-go/1.GO系列之入门" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/29/go/1.GO系列之入门/" class="article-date">
  <time datetime="2016-01-29T05:14:36.000Z" itemprop="datePublished">2016-01-29</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/go/">go</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/29/go/1.GO系列之入门/">Go系列一之入门</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="u5B89_u88C5_u7B2C_u4E09_u65B9_u5E93"><a href="#u5B89_u88C5_u7B2C_u4E09_u65B9_u5E93" class="headerlink" title="安装第三方库"></a>安装第三方库</h2><p>　　以amqp为例：<br>　　1：首先安装GO环境至C:\Go<br>　　2：设置环境变量：GOPATH=C:\Go\code<br>　　3：在C:\Go\code下创建源代码目录src<br>　　4：进入C:\Go\code\src<br>　　5：下载ampq：git clone <a href="https://github.com/streadway/amqp.git" target="_blank" rel="external">https://github.com/streadway/amqp.git</a><br>　　6：在任意目录下执行go install amqp<br>　　7：可以看到amqp安装到了C:\Go\code\pkg目录下<br>　　8：直接在go中引入amqp：import amqp</p>
<h2 id="u5206_u6A21_u5757_u5F00_u53D1"><a href="#u5206_u6A21_u5757_u5F00_u53D1" class="headerlink" title="分模块开发"></a>分模块开发</h2><p>　　1. 设置环境变量：GOPATH=C:\Go\code<br>　　2. 源码放置在C:\Go\code\src中，一个包对应一个文件夹<img src="/images/go-modules.png" alt="go-modules.png"></p>
<h2 id="u53C2_u8003_u8D44_u6599"><a href="#u53C2_u8003_u8D44_u6599" class="headerlink" title="参考资料"></a>参考资料</h2><p><a href="http://www.golangtc.com/" target="_blank" rel="external">http://www.golangtc.com/</a><br><a href="http://www.01happy.com/golang-tcp-socket-adhere/" target="_blank" rel="external">http://www.01happy.com/golang-tcp-socket-adhere/</a><br><a href="http://www.cnblogs.com/sevenyuan/archive/2013/02/28/2936494.html" target="_blank" rel="external">http://www.cnblogs.com/sevenyuan/archive/2013/02/28/2936494.html</a><br><a href="http://my.oschina.net/u/139611/blog/166959" target="_blank" rel="external">http://my.oschina.net/u/139611/blog/166959</a><br><a href="http://studygolang.com/p/logs" target="_blank" rel="external">http://studygolang.com/p/logs</a><br><a href="http://docscn.studygolang.com/doc/effective_go.html#Web服务器" target="_blank" rel="external">http://docscn.studygolang.com/doc/effective_go.html#Web服务器</a><br><a href="http://www.jb51.net/article/57335.htm" target="_blank" rel="external">http://www.jb51.net/article/57335.htm</a><br><a href="https://bitbucket.org/gotamer/tuple/src/de2f00cd5ac7?at=master" target="_blank" rel="external">https://bitbucket.org/gotamer/tuple/src/de2f00cd5ac7?at=master</a><br><a href="http://www.open-open.com/lib/view/open1396063913278.html" target="_blank" rel="external">http://www.open-open.com/lib/view/open1396063913278.html</a><br><a href="http://wenku.baidu.com/link?url=cOEy4uem4hxIWj5DLJvfbcRCUu_aAkFONCUp7WoIcfFff1iDMUac5q7A0Iy3Bk6qC5aFpvvf6zdgqxIWC7tTfNt58xoS_cJXH6E5rapqsja" target="_blank" rel="external">http://wenku.baidu.com/link?url=cOEy4uem4hxIWj5DLJvfbcRCUu_aAkFONCUp7WoIcfFff1iDMUac5q7A0Iy3Bk6qC5aFpvvf6zdgqxIWC7tTfNt58xoS_cJXH6E5rapqsja</a><br><a href="http://blog.csdn.net/educast/article/details/35224681" target="_blank" rel="external">http://blog.csdn.net/educast/article/details/35224681</a><br><a href="https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/go" target="_blank" rel="external">https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/go</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/29/go/1.GO系列之入门/" data-id="cijzzpvfa00ep1cfscx46zn25" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/go/">go</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-tomcat/2.tomcat性能优化" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/28/tomcat/2.tomcat性能优化/" class="article-date">
  <time datetime="2016-01-28T11:32:00.000Z" itemprop="datePublished">2016-01-28</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/tomcat/">tomcat</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/28/tomcat/2.tomcat性能优化/">tomcat性能优化</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>　　默认情况下，单个java程序分配的内存是很小的，大概64M。如果需要支持大并发，那么jvm的参数必须进行优化。以下是以tomcat上的jvm参数配置为例。修改catalina.sh（路径 $TOMCAT_HOME/bin) 在catalina.sh中“cygwin=false”前加如下内容：<br>JAVA_OPTS=”-Xms1024M -Xmx10G -XX:+UseParallelGC -XX:ParallelGCThreads=30 -XX:+UseParallelOldGC -XX:PermSize=512M -Xss1024K -XX:MaxPermSize=512M”<br>其中：<br>-Xms1024M  java初始化堆内存为1G<br>-Xmx10G           java最大对内存为10G<br>-XX:+UseParallelGC 采用并行垃圾回收机制<br>-XX:ParallelGCThreads=30 并行回收线程数<br>-XX:+UseParallelOldGC 老年代垃圾回收采用并行回收<br>-XX:PermSize=512M 非堆内存默认512M<br>-XX:MaxPermSize=512M 非堆内存最大为512M<br>-Xss1024K 每个线程享用的内存。<br>　　在实际中应该根据实际情况来修改配置。内存的各项配置之和不得高于物理内存。关于java的内存配置应遵循，java最大堆内存不宜过大，不然容易造成jvm GC时的停顿或则增加Full GC的概率。<br>　　在linux下配置为：</p>
<h1 id="u4E0D_u8BBE-XX_3AHeapDumpPath_u65F6_uFF0Cdump_u51FA_u7684_u6587_u4EF6_u5728/tomcat_home/bin_u76EE_u5F55_u4E0B_uFF1A"><a href="#u4E0D_u8BBE-XX_3AHeapDumpPath_u65F6_uFF0Cdump_u51FA_u7684_u6587_u4EF6_u5728/tomcat_home/bin_u76EE_u5F55_u4E0B_uFF1A" class="headerlink" title="不设-XX:HeapDumpPath时，dump出的文件在/tomcat_home/bin目录下："></a>不设-XX:HeapDumpPath时，dump出的文件在/tomcat_home/bin目录下：</h1><p>JAVA_OPTS=”$JAVA_OPTS -server -Xms256M -Xmx1024M -XX:PermSize=64M -XX:MaxPermSize=256m -Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError”<br>　　默认tomcat支持150个连接。因此在生成环境下，tomcat的并发连接数应该根据实际情况进行调整的。修改server.xml（路径$TOMCAT_HOME/conf)，配置并发连接数参数：</p>
<p><connector port="8080" protocol="HTTP/1.1" connectiontimeout="20000" maxthreads="10000" minsparethreads="50" maxsparethreads="10000" acceptcount="5000" uriencoding="UTF-8" redirectport="8443"><br>其中:<br>Protocol : 使用的协议。默认这个配置是效率最低但是最稳定的。如果对数据稳定要求不高的情况下，可以采用nio的socket.<br>connectionTimeout: 连接超时时间。<br>maxThreads: 最大连接数。<br>minSpareThreads：最小连接数。<br>maxSpareThreads：最大连接数。<br>acceptCount：在达到最大连接限制之后还能接受的连接数。</connector></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/28/tomcat/2.tomcat性能优化/" data-id="cijzzpv0x000w1cfs0gmnlddz" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/tomcat/">tomcat</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-tomcat/1.tomcat虚拟主机" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/28/tomcat/1.tomcat虚拟主机/" class="article-date">
  <time datetime="2016-01-28T11:32:00.000Z" itemprop="datePublished">2016-01-28</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/tomcat/">tomcat</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/28/tomcat/1.tomcat虚拟主机/">tomcat虚拟主机</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="localhost"><a href="#localhost" class="headerlink" title="localhost"></a>localhost</h2><p>　　配置虚似主机就是配置一个网站。在Tomcat配置一个虚拟主机需要修改conf文件夹下的server.xml这个配置文件，使用Host元素进行配置。打开server.xml，可以看到Tomcat自带的一个名称为localhost的虚拟主机，如下图所示：<img src="/images/tomcat-localhost.jpg" alt="tomcat-localhost.jpg"><br>　　平时我们将开发好的JavaWeb应用放到webapps文件夹下，然后就可以使用”<a href="http://localhost:端口号/JavaWebAppName&quot;的方式去访问了，其实访问的就是name是&quot;localhost&quot;的那台虚拟主机(Host)，这台虚拟主机管理webapps文件夹下的所有web应用。例如：http://localhost:8080/JavaWebDemoProject/1.jsp" target="_blank" rel="external">http://localhost:端口号/JavaWebAppName&quot;的方式去访问了，其实访问的就是name是&quot;localhost&quot;的那台虚拟主机(Host)，这台虚拟主机管理webapps文件夹下的所有web应用。例如：http://localhost:8080/JavaWebDemoProject/1.jsp</a> 这个URL地址访问的就是名称是localhost的那台虚拟主机下的JavaWebDemoProject这个应用里面的1.jsp这个web资源。</p>
<h2 id="u914D_u7F6E_u865A_u62DF_u4E3B_u673A"><a href="#u914D_u7F6E_u865A_u62DF_u4E3B_u673A" class="headerlink" title="配置虚拟主机"></a>配置虚拟主机</h2><p>　　下面我们在server.xml中配置一个www.gacl.cn虚拟主机：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="title">Host</span> <span class="attribute">name</span>=<span class="value">"www.gacl.cn"</span> <span class="attribute">appBase</span>=<span class="value">"F:\JavaWebApps"</span>&gt;</span>23<span class="tag">&lt;/<span class="title">Host</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>　　这里新配置的虚拟主机的name是”www.gacl.cn”，现在虚拟主机”www.gacl.cn”管理着JavaWebApps文件夹下的所有web应用，所以当我们要访问name是”www.gacl.cn”的这个虚拟主机时，就可以使用”域名(www.gacl.cn)”去访问，注意一下appBase=”F:\JavaWebApps”，这里的JavaWebApps文件夹代表的不是一个项目的根目录，而是一个存放了一个或者多个JavaWeb应用的文件夹，如下图所示：<img src="/images/tomcat-virtual.jpg" alt="tomcat-virtual.jpg"><br>　　就好像是Tomcat服务器的webapps文件夹一样，里面存放了很多的JavaWeb应用一个道理</p>
<h2 id="windows_u7CFB_u7EDF_u4E2D_u6CE8_u518C_u57DF_u540D"><a href="#windows_u7CFB_u7EDF_u4E2D_u6CE8_u518C_u57DF_u540D" class="headerlink" title="windows系统中注册域名"></a>windows系统中注册域名</h2><p>　　配置的主机(网站)要想通过域名被外部访问，必须在DNS服务器或windows系统中注册访问网站时使用的域名，找到”C:\Windows\System32\drivers\etc”目录下的hosts文件。编辑这个文件，将新添加的网站的域名和IP地址绑定在一起，这样就可以在浏览器中去访问name是www.gacl.cn那个虚拟主机里面管理的那些web应用了。<img src="/images/tomcat-hosts.jpg" alt="tomcat-hosts.jpg"><br>　　使用浏览器通过域名”www.gacl.cn”访问”www.gacl.cn”这个虚拟主机下的JavaWebDemo1这个web应用下的1.jsp这个web资源，”www.gacl.cn”这个虚拟主机开放了一个8080端口，用户只能通过这个8080端口去访问JavaWebDemo1这个web应用下的1.jsp这个web资源。<img src="/images/tomcat-visit.jpg" alt="tomcat-visit.jpg"></p>
<h2 id="Web_u5E94_u7528_u7684_u7EC4_u6210_u7ED3_u6784"><a href="#Web_u5E94_u7528_u7684_u7EC4_u6210_u7ED3_u6784" class="headerlink" title="Web应用的组成结构"></a>Web应用的组成结构</h2><p>　　开发JavaWeb应用时，不同类型的文件有严格的存放规则，否则不仅可能会使web应用无法访问，还会导致web服务器启动报错<img src="/images/tomcat-webapp.png" alt="tomcat-webapp.png"><br>WebRoot →Web应用所在目录，一般情况下虚拟目录要配置到此文件夹当中。<br>  ┝WEB-INF：此文件夹必须位于WebRoot文件夹里面，而且必须以这样的形式去命名，字母都要大写。<br>　 　┝web.xml：配置文件，有格式要求，此文件必须以这样的形式去命名，并且必须放置到WEB-INF文件夹中。<br>web.xml的格式可以直接从Tomcat中参考得到：找到Tomcat目录下的webapps\ROOT\WEB-INF这个目录下的web.xml文件</p>
<h2 id="u6D4F_u89C8_u5668_u4E0E_u670D_u52A1_u5668_u4EA4_u4E92"><a href="#u6D4F_u89C8_u5668_u4E0E_u670D_u52A1_u5668_u4EA4_u4E92" class="headerlink" title="浏览器与服务器交互"></a>浏览器与服务器交互</h2><p><img src="/images/browser-server.png" alt="browser-server.png"><br>　　浏览器和服务器做了以下几个操作：<br>　　1、浏览器根据主机名”www.gacl.cn”去操作系统的Hosts文件中查找主机名对应的IP地址。<br>　　2、浏览器如果在操作系统的Hosts文件中没有找到对应的IP地址，就去互联网上的DNS服务器上查找”www.gacl.cn”这台主机对应的IP地址。<br>　　3、浏览器查找到”www.gacl.cn”这台主机对应的IP地址后，就使用IP地址连接到Web服务器。<br>　　4、浏览器连接到web服务器后，就使用http协议向服务器发送请求，发送请求的过程中，浏览器会向Web服务器以Stream(流)的形式传输数据，告诉Web服务器要访问服务器里面的哪个Web应用下的Web资源，如下图所示：<img src="/images/browser-send.jpg" alt="browser-send.jpg"><br>　　这就是浏览器向Web服务器发请求时向服务器传输的数据，解释一下”GET /JavaWebDemo1/1.jsp HTTP/1.1”这里面的内容，<br>GET：告诉Web服务器，浏览器是以GET的方式向服务器发请求。<br>/JavaWebDemo1/1.jsp：告诉Web服务器，浏览器要访问JavaWebDemo1应用里面的1.jsp这个Web资源。<br>HTTP/1.1：告诉Web服务器，浏览器是以HTTP协议请求的，使用的是1.1的版本。<br>　　5、浏览器做完上面4步工作后，就开始等待，等待Web服务器把自己想要访问的1.jsp这个Web资源传输给它。<br>　　6、服务器接收到浏览器传输的数据后，开始解析接收到的数据，服务器解析”GET /JavaWebDemo1/1.jsp HTTP/1.1”里面的内容时知道客户端浏览器要访问的是JavaWebDemo1应用里面的1.jsp这个Web资源，然后服务器就去读取1.jsp这个Web资源里面的内容，将读到的内容再以Stream(流)的形式传输给浏览器，如下图所示：<img src="/images/tomcat-response.jpg" alt="tomcat-response.jpg"><br>　　7、浏览器拿到服务器传输给它的数据之后，就可以把数据展现给用户看了</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/28/tomcat/1.tomcat虚拟主机/" data-id="cijzzpv1100111cfsufxaa2wv" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/tomcat/">tomcat</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-database/12.索引结构" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/27/database/12.索引结构/" class="article-date">
  <time datetime="2016-01-27T08:13:00.000Z" itemprop="datePublished">2016-01-27</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/database/">database</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/27/database/12.索引结构/">索引结构</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="u80CC_u666F"><a href="#u80CC_u666F" class="headerlink" title="背景"></a>背景</h2><p>　　一般来说，索引本身也很大，不可能全部存储在内存中，因此索引往往以索引文件的形式存储的磁盘上。这样索引查找过程中就要产生磁盘I/O消耗。相对于内存存取，I/O存取的消耗要高几个数量级，所以评价一个数据结构作为索引的优劣最重要的指标就是在查找过程中磁盘I/O操作次数的渐进复杂度。换句话说，索引的结构组织要尽量减少查找过程中磁盘I/O的存取次数。下面先介绍内存和磁盘存取原理，然后再结合这些原理分析B-/+Tree作为索引的效率。</p>
<h2 id="hash_u7D22_u5F15"><a href="#hash_u7D22_u5F15" class="headerlink" title="hash索引"></a>hash索引</h2><p>　　目前我所知道的就只有memory和ndb cluster支持这种索引。hash索引由于其结构，所以在每次查询的时候直接一次到位，不像b-tree那样一点点的前进。所以hash索引的效率高于b-tree，但hash也有缺点，主要如下<br>　　1. 由于存放的是hash值，所以仅支持”=”,”&lt;=&gt;”以及”in”操作<br>　　2. hash索引无法通过操作索引来排序，这是因为存放的时候经过hash计算，但是计算的hash值和存放的不一定相等，所以无法排序<br>　　3. 在组合索引里，无法对部分使用索引.<br>　　4. 不能避免全表扫描，只是由于在memory表里支持非唯一值hash索引，<br>　　5. 当存在大量相同hash值得时候，hash索引的效率会变低.</p>
<h2 id="BTree"><a href="#BTree" class="headerlink" title="BTree"></a>BTree</h2><p>　　BTree应该是mysql里最广泛的索引，数据本身的组织结构不可能完全满足各种数据结构（例如，理论上不可能同时将两列都按顺序进行组织），所以，在数据之外，数据库系统还维护着满足特定查找算法的数据结构，这些数据结构以某种方式引用（指向）数据，这样就可以在这些数据结构上实现高级查找算法。这种数据结构，就是索引。<br>　　每个数据BLOCK组成BTREE索引的一个节点，一个索引节点主要包括两方面的数据，一方面是索引字段的值和rowid，另一方面是指向另一个节点的指针(指向对应数据记录物理地址的指针)，如下图所示：<img src="/images/btree.jpg" alt="btree.jpg"><br>　　上图展示了一种可能的索引方式。左边是数据表，一共有两列七条记录，最左边的是数据记录的物理地址（注意逻辑上相邻的记录在磁盘上也并不是一定物理相邻的）。<br>　　为了加快Col2的查找，可以维护一个右边所示的二叉查找树，每个节点分别包含索引键值和一个指向对应数据记录物理地址的指针，这样就可以运用二叉查找在O(log2n)的复杂度内获取到相应数据。虽然这是一个货真价实的索引，但是实际的数据库系统几乎没有使用二叉查找树或其进化品种红黑树（red-black tree）实现的，原因会在下文介绍。<br>　　为了描述B-Tree，首先定义一条数据记录为一个二元组[key, data]，key为记录的键值，对于不同数据记录，key是互不相同的；data为数据记录除key外的数据;</p>
<h2 id="u53C2_u8003_u94FE_u63A5"><a href="#u53C2_u8003_u94FE_u63A5" class="headerlink" title="参考链接"></a>参考链接</h2><p><a href="http://blog.linezing.com/?p=798#nav-2-2" target="_blank" rel="external">http://blog.linezing.com/?p=798#nav-2-2</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/27/database/12.索引结构/" data-id="cijzzpvhu00gx1cfs7rhwnsvb" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/database/">database</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-database/13.事务" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/27/database/13.事务/" class="article-date">
  <time datetime="2016-01-27T08:13:00.000Z" itemprop="datePublished">2016-01-27</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/database/">database</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/27/database/13.事务/">事物与锁</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="ACID"><a href="#ACID" class="headerlink" title="ACID"></a>ACID</h2><p>　　<strong>原子性</strong>（Atomicity）：原子性是指事务是一个不可分割的工作单位，事务中的操作要么全部成功，要么全部失败。比如在同一个事务中的SQL语句，要么全部执行成功，要么全部执行失败<br>　　<strong>一致性</strong>（Consistency）：事务必须使数据库从一个一致性状态变换到另外一个一致性状态。以转账为例子，A向B转账，假设转账之前这两个用户的钱加起来总共是2000，那么A向B转账之后，不管这两个账户怎么转，A用户的钱和B用户的钱加起来的总额还是2000，这个就是事务的一致性。<br>　　<strong>隔离性</strong>（Isolation）：事务的隔离性是多个用户并发访问数据库时，数据库为每一个用户开启的事务，不能被其他事务的操作数据所干扰，多个并发事务之间要相互隔离。<br>　　<strong>持久性</strong>（Durability）：一个事务一旦被提交，它对数据库中数据的改变就是永久性的，接下来即使数据库发生故障也不应该对其有任何影响<br>　　事务的四大特性中最麻烦的是隔离性，下面重点介绍一下事务的隔离级别</p>
<h2 id="u9694_u79BB_u6027_u5F15_u53D1_u7684_u95EE_u9898"><a href="#u9694_u79BB_u6027_u5F15_u53D1_u7684_u95EE_u9898" class="headerlink" title="隔离性引发的问题"></a>隔离性引发的问题　　</h2><p>　　事务隔离级别：<strong>一个事务</strong>对数据库的修改与<strong>并行的另一个事务</strong>的隔离程度。两个并发事务同时访问数据库表相同的行时，可能存在以下三个问题：</p>
<h4 id="u810F_u8BFB"><a href="#u810F_u8BFB" class="headerlink" title="脏读"></a>脏读</h4><p>　　脏读指<strong>一个事务读取了另外一个事务未提交的数据（同一条数据）</strong>。假设Ａ向Ｂ转帐100元，对应sql语句如下所示<br><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">update account set money=money+<span class="number">100</span> where name=<span class="string">'B'</span>;    </span><br><span class="line">update account set money=money-<span class="number">100</span>  where name=<span class="string">'A'</span>;</span><br></pre></td></tr></table></figure></p>
<p>　　当第1条sql执行完，第2条还没执行(A未提交时)，如果此时Ｂ查询自己的帐户，就会发现自己多了100元钱。如果A等B走后再回滚，B就会损失100元。　　</p>
<h4 id="u4E0D_u53EF_u91CD_u590D_u8BFB"><a href="#u4E0D_u53EF_u91CD_u590D_u8BFB" class="headerlink" title="不可重复读"></a>不可重复读</h4><p>　　不可重复读指<strong>在一个事务内读取表中的某一行数据，多次读取结果不同</strong>。例如银行想查询A帐户余额，第一次查询A帐户为200元，此时A向帐户内存了100元并提交了，银行接着又进行了一次查询，此时A帐户为300元了。银行两次查询不一致，可能就会很困惑，不知道哪次查询是准的。<br>　　不可重复读和脏读的区别是，<strong>脏读是读取了其他事务未提交的数据</strong>，不可重复读是重新读取了前一事务已提交的数据。<br>　　很多人认为这种情况就对了，无须困惑，当然是后面的为准。我们可以考虑这样一种情况，比如银行程序需要将查询结果分别输出到电脑屏幕和写到文件中，结果在一个事务中针对输出的目的地，进行的两次查询不一致，导致文件和屏幕中的结果不一致，银行工作人员就不知道以哪个为准了。</p>
<h4 id="u865A_u8BFB_28_u5E7B_u8BFB_29"><a href="#u865A_u8BFB_28_u5E7B_u8BFB_29" class="headerlink" title="虚读(幻读)"></a>虚读(幻读)</h4><p>　　虚读(幻读)是指<strong>在一个事务内读取到了别的事务插入的数据</strong>，导致前后读取不一致。<br>　　如丙存款100元未提交，这时银行做报表统计account表中所有用户的总额为500元，然后丙提交了，这时银行再统计发现帐户为600元了，造成虚读。</p>
<h2 id="u4E8B_u52A1_u9694_u79BB_u6027_u8BBE_u7F6E"><a href="#u4E8B_u52A1_u9694_u79BB_u6027_u8BBE_u7F6E" class="headerlink" title="事务隔离性设置"></a>事务隔离性设置</h2><p>　　MySQL数据库共定义了四种隔离级别：<br>　　1. Serializable(串行化)：可避免脏读、不可重复读、虚读情况的发生。<br>　　2. Repeatable read(可重复读)：可避免脏读、不可重复读情况的发生。<br>　　3. Read committed(读已提交)：可避免脏读情况发生。<br>　　4. Read uncommitted(读未提交)：最低级别，以上情况均无法保证。<br>　　查询事务隔离级别：select @@tx_isolation。mysql数据库默认的事务隔离级别是：Repeatable read(可重复读)<br>　　设置事务隔离级别：set transaction isolation level 隔离级别名</p>
<h2 id="u5E38_u7528_u65B9_u6CD5"><a href="#u5E38_u7528_u65B9_u6CD5" class="headerlink" title="常用方法"></a>常用方法</h2><p>Connection.setAutoCommit(false);//开启事务(start transaction)<br>Connection.rollback();//回滚事务(rollback)<br>Connection.commit();//提交事务(commit)</p>
<h2 id="u5B9E_u6218"><a href="#u5B9E_u6218" class="headerlink" title="实战"></a>实战</h2><p>　　下面使用MySQL数据库演示不同隔离级别下的并发问题，需要同时打开两个窗口模拟2个用户并发访问数据库。</p>
<h4 id="u5F53_u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3Aread_uncommitted_u65F6_uFF0C_u4F1A_u5F15_u53D1_u810F_u8BFB_u3001_u4E0D_u53EF_u91CD_u590D_u8BFB_u548C_u865A_u8BFB"><a href="#u5F53_u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3Aread_uncommitted_u65F6_uFF0C_u4F1A_u5F15_u53D1_u810F_u8BFB_u3001_u4E0D_u53EF_u91CD_u590D_u8BFB_u548C_u865A_u8BFB" class="headerlink" title="当把事务的隔离级别设置为read uncommitted时，会引发脏读、不可重复读和虚读"></a>当把事务的隔离级别设置为read uncommitted时，会引发脏读、不可重复读和虚读</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- A窗口</span></span><br><span class="line"><span class="comment">-- 设置A用户的隔离级别为Read uncommitted(即可以读取其他事物未提交的数据)</span></span><br><span class="line"><span class="operator"><span class="keyword">set</span> <span class="keyword">transaction</span> <span class="keyword">isolation</span> <span class="keyword">level</span> <span class="keyword">read</span> uncommitted;</span></span><br><span class="line"><span class="comment">-- 开启事务</span></span><br><span class="line"><span class="operator"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="comment">-- 查询A账户中的钱，再转到B窗口进行操作</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">account</span>;</span></span><br><span class="line"><span class="comment">-- 发现a多了100元，这时候A读到了B未提交的数据（脏读）</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">account</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- B窗口</span></span><br><span class="line"><span class="comment">--开启事务</span></span><br><span class="line"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="comment">--不要提交，转到A窗口查询</span></span><br><span class="line"><span class="operator"><span class="keyword">update</span> <span class="keyword">account</span> <span class="keyword">set</span> money=money+<span class="number">100</span> <span class="keyword">where</span> <span class="keyword">name</span>=<span class="string">'A'</span>;</span></span><br></pre></td></tr></table></figure>
<h4 id="u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3Aread_committed_u65F6_uFF0C_u4F1A_u5F15_u53D1_u4E0D_u53EF_u91CD_u590D_u8BFB_u548C_u865A_u8BFB_uFF0C_u4F46_u907F_u514D_u4E86_u810F_u8BFB"><a href="#u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3Aread_committed_u65F6_uFF0C_u4F1A_u5F15_u53D1_u4E0D_u53EF_u91CD_u590D_u8BFB_u548C_u865A_u8BFB_uFF0C_u4F46_u907F_u514D_u4E86_u810F_u8BFB" class="headerlink" title="把事务的隔离级别设置为read committed时，会引发不可重复读和虚读，但避免了脏读"></a>把事务的隔离级别设置为read committed时，会引发不可重复读和虚读，但避免了脏读</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- A窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">set</span> <span class="keyword">transaction</span> <span class="keyword">isolation</span> <span class="keyword">level</span> <span class="keyword">read</span> committed;</span></span><br><span class="line"><span class="operator"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="comment">-- a帐户是1000元，转到b窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">account</span>;</span></span><br><span class="line"><span class="comment">-- a帐户多了100，a读到了别的事务提交的数据，两次读取a帐户读到的是不同的结果（不可重复读，对同一条数据的操作）</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">account</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- B窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">update</span> <span class="keyword">account</span> <span class="keyword">set</span> money=money+<span class="number">100</span> <span class="keyword">where</span> <span class="keyword">name</span>=<span class="string">'aaa'</span>;</span></span><br><span class="line"><span class="comment">-- 转到a窗口，与1中的区别，多了提交事物</span></span><br><span class="line"><span class="operator"><span class="keyword">commit</span>;</span></span><br></pre></td></tr></table></figure>
<h4 id="u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3Arepeatable_read_28mysql_u9ED8_u8BA4_u7EA7_u522B_29_u65F6_uFF0C_u4F1A_u5F15_u53D1_u865A_u8BFB_uFF0C_u4F46_u907F_u514D_u4E86_u810F_u8BFB_u3001_u4E0D_u53EF_u91CD_u590D_u8BFB"><a href="#u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3Arepeatable_read_28mysql_u9ED8_u8BA4_u7EA7_u522B_29_u65F6_uFF0C_u4F1A_u5F15_u53D1_u865A_u8BFB_uFF0C_u4F46_u907F_u514D_u4E86_u810F_u8BFB_u3001_u4E0D_u53EF_u91CD_u590D_u8BFB" class="headerlink" title="把事务的隔离级别设置为repeatable read(mysql默认级别)时，会引发虚读，但避免了脏读、不可重复读"></a>把事务的隔离级别设置为repeatable read(mysql默认级别)时，会引发虚读，但避免了脏读、不可重复读</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- A窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">set</span> <span class="keyword">transaction</span> <span class="keyword">isolation</span> <span class="keyword">level</span> repeatable <span class="keyword">read</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="comment">-- 表有4个记录，转到b窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">account</span>;</span></span><br><span class="line"><span class="comment">-- 表有5条记录，这时候发生了a读取到另外一个事务插入的数据（虚读）</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">account</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- B窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">insert</span> <span class="keyword">into</span> <span class="keyword">account</span>(<span class="keyword">name</span>,money) <span class="keyword">values</span>(<span class="string">'ggg'</span>,<span class="number">1000</span>);</span></span><br><span class="line"><span class="comment">-- 转到a窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">commit</span>;</span></span><br></pre></td></tr></table></figure>
<h4 id="u5F53_u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3ASerializable_u65F6_uFF0C_u4F1A_u907F_u514D_u6240_u6709_u95EE_u9898"><a href="#u5F53_u628A_u4E8B_u52A1_u7684_u9694_u79BB_u7EA7_u522B_u8BBE_u7F6E_u4E3ASerializable_u65F6_uFF0C_u4F1A_u907F_u514D_u6240_u6709_u95EE_u9898" class="headerlink" title="当把事务的隔离级别设置为Serializable时，会避免所有问题"></a>当把事务的隔离级别设置为Serializable时，会避免所有问题</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- A窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">set</span> <span class="keyword">transaction</span> <span class="keyword">isolation</span> <span class="keyword">level</span> <span class="keyword">Serializable</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">account</span>;</span><span class="comment">--转到b窗口</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- B窗口</span></span><br><span class="line"><span class="operator"><span class="keyword">start</span> <span class="keyword">transaction</span>;</span></span><br><span class="line"><span class="comment">-- 发现不能插入，只能等待a结束事务才能插入</span></span><br><span class="line"><span class="operator"><span class="keyword">insert</span> <span class="keyword">into</span> <span class="keyword">account</span>(<span class="keyword">name</span>,money) <span class="keyword">values</span>(<span class="string">'ggg'</span>,<span class="number">1000</span>);</span></span><br></pre></td></tr></table></figure>
<h2 id="u8BBE_u7F6E_u4E8B_u52A1_u56DE_u6EDA_u70B9"><a href="#u8BBE_u7F6E_u4E8B_u52A1_u56DE_u6EDA_u70B9" class="headerlink" title="设置事务回滚点"></a>设置事务回滚点</h2><p>在开发中，有时候可能需要手动设置事务的回滚点，在JDBC中使用如下的语句设置事务回滚点<br>Savepoint sp = conn.setSavepoint();<br>Conn.rollback(sp);<br>Conn.commit();//回滚后必须通知数据库提交事务</p>
<h2 id="u8BFB_u5199_u9501"><a href="#u8BFB_u5199_u9501" class="headerlink" title="读写锁"></a>读写锁</h2><p>　　排他锁（写锁）exclusive lock：写锁会阻塞其他的写锁和读锁。<br>　　共享锁（读锁）shared lock：读锁是共享的，是相互不阻塞的。<br>　　写锁有更高的优先级，写锁请求可能会插入到锁队列中读锁的前面，但读锁不能插入到写锁的前面<br>　　死锁：资源请求相互等待，可以设置锁等待超时后放弃锁请求，处理方式不好，目前InnoDB处理方式是将持有最少行级排他锁的事物进行回滚</p>
<h4 id="u9501_u7C92_u5EA6"><a href="#u9501_u7C92_u5EA6" class="headerlink" title="锁粒度"></a>锁粒度</h4><p>　　表锁：开销最小的策略，特定场景中性能良好，如read local表锁支持某些类型的并发写操作<br>　　行级锁：最大程度支持并发处理（存储引擎层实现）</p>
<h4 id="u60B2_u89C2_u9501"><a href="#u60B2_u89C2_u9501" class="headerlink" title="悲观锁"></a>悲观锁</h4><p>　　每次在拿数据的时候都会上锁，这样别人想拿这个数据就会block直到它拿到锁。传统的关系型数据库里边就用到了很多这种锁机制，比如<strong>行锁、表锁、读锁、写锁等，都是在做操作之前先上锁，属于悲观锁</strong>。</p>
<h4 id="u4E50_u89C2_u9501"><a href="#u4E50_u89C2_u9501" class="headerlink" title="乐观锁"></a>乐观锁</h4><p>　　每次去拿数据的时候都认为别人不会修改，所以不会上锁，但是<strong>在更新的时候会判断在此期间别人有没有去更新这个数据</strong>，可以使用版本号等机制。乐观锁适用于多读的应用类型，这样可以提高吞吐量，像数据库如果提供类似于write_condition机制的其实都是提供的乐观锁。在数据进行提交更新的时候，才会对数据的冲突与否进行检测，如果发现冲突了，则让用户返回错误的信息，让用户决定如何去做。</p>
<h2 id="u53C2_u8003_u94FE_u63A5"><a href="#u53C2_u8003_u94FE_u63A5" class="headerlink" title="参考链接"></a>参考链接</h2><p><a href="http://blog.linezing.com/?p=798#nav-2-2" target="_blank" rel="external">http://blog.linezing.com/?p=798#nav-2-2</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/27/database/13.事务/" data-id="cijzzpvhq00gu1cfsnq61ozbd" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/database/">database</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-database/11.java调用oracle存储过程" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/27/database/11.java调用oracle存储过程/" class="article-date">
  <time datetime="2016-01-27T08:07:00.000Z" itemprop="datePublished">2016-01-27</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/database/">database</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/27/database/11.java调用oracle存储过程/">oracle spatial</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="u65E0_u8FD4_u56DE_u503C_u7684_u5B58_u50A8_u8FC7_u7A0B"><a href="#u65E0_u8FD4_u56DE_u503C_u7684_u5B58_u50A8_u8FC7_u7A0B" class="headerlink" title="无返回值的存储过程"></a>无返回值的存储过程</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="operator"><span class="keyword">CREATE</span> <span class="keyword">OR</span> <span class="keyword">REPLACE</span> <span class="keyword">PROCEDURE</span> TESTA(PARA1 <span class="keyword">IN</span> VARCHAR2,PARA2 <span class="keyword">IN</span> VARCHAR2)  <span class="keyword">AS</span></span><br><span class="line"><span class="keyword">BEGIN</span></span><br><span class="line">   <span class="keyword">INSERT</span> <span class="keyword">INTO</span> HYQ.B_ID (I_ID,I_NAME) <span class="keyword">VALUES</span> (PARA1, PARA2);</span></span><br><span class="line"><span class="operator"><span class="keyword">END</span> TESTA;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.hyq.src;</span><br><span class="line"> </span><br><span class="line"><span class="keyword">import</span> java.sql.*;</span><br><span class="line"><span class="keyword">import</span> java.sql.ResultSet;</span><br><span class="line"> </span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestProcedureOne</span> </span>&#123;</span><br><span class="line">  <span class="function"><span class="keyword">public</span> <span class="title">TestProcedureOne</span><span class="params">()</span> </span>&#123;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args )</span></span>&#123;</span><br><span class="line">    String driver = <span class="string">"oracle.jdbc.driver.OracleDriver"</span>;</span><br><span class="line">    String strUrl = <span class="string">"jdbc:oracle:thin:@127.0.0.1:1521: hyq "</span>;</span><br><span class="line">    Statement stmt = <span class="keyword">null</span>;</span><br><span class="line">    ResultSet rs = <span class="keyword">null</span>;</span><br><span class="line">    Connection conn = <span class="keyword">null</span>;</span><br><span class="line">    CallableStatement cstmt = <span class="keyword">null</span>;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">      Class.forName(driver);</span><br><span class="line">      conn =  DriverManager.getConnection(strUrl, <span class="string">" hyq "</span>, <span class="string">" hyq "</span>);</span><br><span class="line">      CallableStatement proc = <span class="keyword">null</span>;</span><br><span class="line">      proc = conn.prepareCall(<span class="string">"&#123; call HYQ.TESTA(?,?) &#125;"</span>);</span><br><span class="line">      proc.setString(<span class="number">1</span>, <span class="string">"100"</span>);</span><br><span class="line">      proc.setString(<span class="number">2</span>, <span class="string">"TestOne"</span>);</span><br><span class="line">      proc.execute();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">catch</span> (SQLException ex2) &#123;</span><br><span class="line">      ex2.printStackTrace();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">catch</span> (Exception ex2) &#123;</span><br><span class="line">      ex2.printStackTrace();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">finally</span>&#123;</span><br><span class="line">      <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="keyword">if</span>(rs != <span class="keyword">null</span>)&#123;</span><br><span class="line">          rs.close();</span><br><span class="line">          <span class="keyword">if</span>(stmt!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            stmt.close();</span><br><span class="line">          &#125;</span><br><span class="line">          <span class="keyword">if</span>(conn!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            conn.close();</span><br><span class="line">          &#125;</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="keyword">catch</span> (SQLException ex1) &#123;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="u6709_u8FD4_u56DE_u503C_u7684_u5B58_u50A8_u8FC7_u7A0B_uFF08_u975E_u5217_u8868_uFF09"><a href="#u6709_u8FD4_u56DE_u503C_u7684_u5B58_u50A8_u8FC7_u7A0B_uFF08_u975E_u5217_u8868_uFF09" class="headerlink" title="有返回值的存储过程（非列表）"></a>有返回值的存储过程（非列表）</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="operator"><span class="keyword">CREATE</span> <span class="keyword">OR</span> <span class="keyword">REPLACE</span> <span class="keyword">PROCEDURE</span> TESTB(PARA1 <span class="keyword">IN</span> VARCHAR2,PARA2 <span class="keyword">OUT</span> VARCHAR2)  <span class="keyword">AS</span></span><br><span class="line"><span class="keyword">BEGIN</span></span><br><span class="line">   <span class="keyword">SELECT</span> <span class="keyword">INTO</span> PARA2 <span class="keyword">FROM</span> TESTTB <span class="keyword">WHERE</span> I_ID= PARA1;</span></span><br><span class="line"><span class="operator"><span class="keyword">END</span> TESTB;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.hyq.src;</span><br><span class="line"> </span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestProcedureTWO</span> </span>&#123;</span><br><span class="line">  <span class="function"><span class="keyword">public</span> <span class="title">TestProcedureTWO</span><span class="params">()</span> </span>&#123;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args )</span></span>&#123;</span><br><span class="line">    String driver = <span class="string">"oracle.jdbc.driver.OracleDriver"</span>;</span><br><span class="line">    String strUrl = <span class="string">"jdbc:oracle:thin:@127.0.0.1:1521:hyq"</span>;</span><br><span class="line">    Statement stmt = <span class="keyword">null</span>;</span><br><span class="line">    ResultSet rs = <span class="keyword">null</span>;</span><br><span class="line">    Connection conn = <span class="keyword">null</span>;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">      Class.forName(driver);</span><br><span class="line">      conn =  DriverManager.getConnection(strUrl, <span class="string">" hyq "</span>, <span class="string">" hyq "</span>);</span><br><span class="line">      CallableStatement proc = <span class="keyword">null</span>;</span><br><span class="line">      proc = conn.prepareCall(<span class="string">"&#123; call HYQ.TESTB(?,?) &#125;"</span>);</span><br><span class="line">      proc.setString(<span class="number">1</span>, <span class="string">"100"</span>);</span><br><span class="line">      proc.registerOutParameter(<span class="number">2</span>, Types.VARCHAR);</span><br><span class="line">      proc.execute();</span><br><span class="line">      String testPrint = proc.getString(<span class="number">2</span>);</span><br><span class="line">      System.out.println(<span class="string">"=testPrint=is="</span>+testPrint);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">catch</span> (SQLException ex2) &#123;</span><br><span class="line">      ex2.printStackTrace();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">catch</span> (Exception ex2) &#123;</span><br><span class="line">      ex2.printStackTrace();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">finally</span>&#123;</span><br><span class="line">      <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="keyword">if</span>(rs != <span class="keyword">null</span>)&#123;</span><br><span class="line">          rs.close();</span><br><span class="line">          <span class="keyword">if</span>(stmt!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            stmt.close();</span><br><span class="line">          &#125;</span><br><span class="line">          <span class="keyword">if</span>(conn!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            conn.close();</span><br><span class="line">          &#125;</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="keyword">catch</span> (SQLException ex1) &#123;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>　　注意，这里的proc.getString(2)中的数值2并非任意的，而是和存储过程中的out列对应的，如果out是在第一个位置，那就是proc.getString(1)，如果是第三个位置，就是proc.getString(3)，当然也可以同时有多个返回值，那就是再多加几个out参数了。</p>
<h2 id="u8FD4_u56DE_u5217_u8868"><a href="#u8FD4_u56DE_u5217_u8868" class="headerlink" title="返回列表"></a>返回列表</h2><p>　　由于oracle存储过程没有返回值，它的所有返回值都是通过out参数来替代的，列表同样也不例外，但由于是集合，所以不能用一般的参数，必须要用pagkage，如下所示：<br><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 建一个程序包。如下：</span></span><br><span class="line"><span class="operator"><span class="keyword">CREATE</span> <span class="keyword">OR</span> <span class="keyword">REPLACE</span> <span class="keyword">PACKAGE</span> TESTPACKAGE <span class="keyword">AS</span></span><br><span class="line">    <span class="keyword">TYPE</span> Test_CURSOR <span class="keyword">IS</span> <span class="keyword">REF</span> <span class="keyword">CURSOR</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">end</span> TESTPACKAGE;</span></span><br><span class="line"><span class="comment">-- 建立存储过程，存储过程为：</span></span><br><span class="line"><span class="operator"><span class="keyword">CREATE</span> <span class="keyword">OR</span> <span class="keyword">REPLACE</span> <span class="keyword">PROCEDURE</span> TESTC(p_CURSOR <span class="keyword">out</span> TESTPACKAGE.Test_CURSOR) <span class="keyword">IS</span></span><br><span class="line"><span class="keyword">BEGIN</span></span><br><span class="line">    <span class="keyword">OPEN</span> p_CURSOR <span class="keyword">FOR</span> <span class="keyword">SELECT</span> * <span class="keyword">FROM</span> HYQ.TESTTB;</span></span><br><span class="line"><span class="operator"><span class="keyword">END</span> TESTC;</span></span><br><span class="line">可以看到，它是把游标（可以理解为一个指针），作为一个out 参数来返回值的。</span><br></pre></td></tr></table></figure></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.hyq.src;</span><br><span class="line"><span class="keyword">import</span> java.sql.*;</span><br><span class="line"><span class="keyword">import</span> java.io.OutputStream;</span><br><span class="line"><span class="keyword">import</span> java.io.Writer;</span><br><span class="line"><span class="keyword">import</span> java.sql.PreparedStatement;</span><br><span class="line"><span class="keyword">import</span> java.sql.ResultSet;</span><br><span class="line"><span class="keyword">import</span> oracle.jdbc.driver.*;</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestProcedureTHREE</span> </span>&#123;</span><br><span class="line">  <span class="function"><span class="keyword">public</span> <span class="title">TestProcedureTHREE</span><span class="params">()</span> </span>&#123;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args )</span></span>&#123;</span><br><span class="line">    String driver = <span class="string">"oracle.jdbc.driver.OracleDriver"</span>;</span><br><span class="line">    String strUrl = <span class="string">"jdbc:oracle:thin:@127.0.0.1:1521:hyq"</span>;</span><br><span class="line">    Statement stmt = <span class="keyword">null</span>;</span><br><span class="line">    ResultSet rs = <span class="keyword">null</span>;</span><br><span class="line">    Connection conn = <span class="keyword">null</span>;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">      Class.forName(driver);</span><br><span class="line">      conn =  DriverManager.getConnection(strUrl, <span class="string">"hyq"</span>, <span class="string">"hyq"</span>);</span><br><span class="line"> </span><br><span class="line">      CallableStatement proc = <span class="keyword">null</span>;</span><br><span class="line">      proc = conn.prepareCall(<span class="string">"&#123; call hyq.testc(?) &#125;"</span>);</span><br><span class="line">      proc.registerOutParameter(<span class="number">1</span>,oracle.jdbc.OracleTypes.CURSOR);</span><br><span class="line">      proc.execute();</span><br><span class="line">      rs = (ResultSet)proc.getObject(<span class="number">1</span>);</span><br><span class="line"> </span><br><span class="line">      <span class="keyword">while</span>(rs.next())</span><br><span class="line">      &#123;</span><br><span class="line">          System.out.println(<span class="string">"&lt;tr&gt;&lt;td&gt;"</span> + rs.getString(<span class="number">1</span>) + <span class="string">"&lt;/td&gt;&lt;td&gt;"</span>+rs.getString(<span class="number">2</span>)+<span class="string">"&lt;/td&gt;&lt;/tr&gt;"</span>);</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">catch</span> (SQLException ex2) &#123;</span><br><span class="line">      ex2.printStackTrace();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">catch</span> (Exception ex2) &#123;</span><br><span class="line">      ex2.printStackTrace();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">finally</span>&#123;</span><br><span class="line">      <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="keyword">if</span>(rs != <span class="keyword">null</span>)&#123;</span><br><span class="line">          rs.close();</span><br><span class="line">          <span class="keyword">if</span>(stmt!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            stmt.close();</span><br><span class="line">          &#125;</span><br><span class="line">          <span class="keyword">if</span>(conn!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            conn.close();</span><br><span class="line">          &#125;</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="keyword">catch</span> (SQLException ex1) &#123;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="u53C2_u8003_u94FE_u63A5"><a href="#u53C2_u8003_u94FE_u63A5" class="headerlink" title="参考链接"></a>参考链接</h2><p>原文链接：<a href="http://www.blogjava.net/TrampEagle/archive/2005/12/13/23605.html" target="_blank" rel="external">http://www.blogjava.net/TrampEagle/archive/2005/12/13/23605.html</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/27/database/11.java调用oracle存储过程/" data-id="cijzzpvhx00h01cfsy18f8wx8" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/database/">database</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-database/10.oracle spatial" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/27/database/10.oracle spatial/" class="article-date">
  <time datetime="2016-01-27T08:07:00.000Z" itemprop="datePublished">2016-01-27</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/database/">database</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/27/database/10.oracle spatial/">oracle spatial</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br></pre></td><td class="code"><pre><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> user_sdo_geom_metadata;</span></span><br><span class="line"><span class="operator"><span class="keyword">delete</span> <span class="keyword">from</span> user_sdo_geom_metadata <span class="keyword">where</span> table_name <span class="keyword">in</span> (<span class="string">'VGNSS'</span>, <span class="string">'VGEOCONPOINT'</span>, <span class="string">'VLEVELLINE'</span>);</span></span><br><span class="line"><span class="operator"><span class="keyword">delete</span> <span class="keyword">from</span> user_sdo_geom_metadata <span class="keyword">where</span> table_name <span class="keyword">in</span> (<span class="string">'TGNSS'</span>, <span class="string">'TGEOCONPOINT'</span>, <span class="string">'TLEVELLINE'</span>);</span></span><br><span class="line"></span><br><span class="line"><span class="operator"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> user_sdo_geom_metadata</span><br><span class="line">  (table_name, column_name, diminfo, srid)</span><br><span class="line"><span class="keyword">VALUES</span></span><br><span class="line">  (<span class="string">'TGNSS'</span>, <span class="comment">-- 表名</span></span><br><span class="line">   <span class="string">'GEOM'</span>, <span class="comment">-- geometry字段</span></span><br><span class="line">   SDO_DIM_ARRAY <span class="comment">-- DIMINFO 属性存储空间表中空间数据的范围和容差</span></span><br><span class="line">   (SDO_DIM_ELEMENT(<span class="string">'X'</span>, <span class="comment">-- 第一个元键名称</span></span><br><span class="line">                    -<span class="number">180</span>, <span class="comment">-- 最小X</span></span><br><span class="line">                    <span class="number">180</span>, <span class="comment">-- 最大X</span></span><br><span class="line">                    <span class="number">0.005</span>), <span class="comment">-- 容差0.005度</span></span><br><span class="line">    SDO_DIM_ELEMENT(<span class="string">'Y'</span>, <span class="comment">-- 第二个元键名称</span></span><br><span class="line">                    -<span class="number">90</span>, <span class="comment">-- 最小Y</span></span><br><span class="line">                    <span class="number">90</span>, <span class="comment">-- 最大Y</span></span><br><span class="line">                    <span class="number">0.005</span>) <span class="comment">-- 容差0.005度</span></span><br><span class="line">    ),</span><br><span class="line">   <span class="number">4326</span></span><br><span class="line">   <span class="comment">--8307 -- SRID</span></span><br><span class="line">   );</span></span><br><span class="line"></span><br><span class="line"><span class="operator"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> user_sdo_geom_metadata</span><br><span class="line">  (table_name, column_name, diminfo, srid)</span><br><span class="line"><span class="keyword">VALUES</span></span><br><span class="line">  (<span class="string">'TGEOCONPOINT'</span>, <span class="comment">-- 表名</span></span><br><span class="line">   <span class="string">'GEOM'</span>, <span class="comment">-- geometry字段</span></span><br><span class="line">   SDO_DIM_ARRAY <span class="comment">-- DIMINFO 属性存储空间表中空间数据的范围和容差</span></span><br><span class="line">   (SDO_DIM_ELEMENT(<span class="string">'X'</span>, <span class="comment">-- 第一个元键名称</span></span><br><span class="line">                    -<span class="number">180</span>, <span class="comment">-- 最小X</span></span><br><span class="line">                    <span class="number">180</span>, <span class="comment">-- 最大X</span></span><br><span class="line">                    <span class="number">0.005</span>), <span class="comment">-- 容差0.005度</span></span><br><span class="line">    SDO_DIM_ELEMENT(<span class="string">'Y'</span>, <span class="comment">-- 第二个元键名称</span></span><br><span class="line">                    -<span class="number">90</span>, <span class="comment">-- 最小Y</span></span><br><span class="line">                    <span class="number">90</span>, <span class="comment">-- 最大Y</span></span><br><span class="line">                    <span class="number">0.005</span>) <span class="comment">-- 容差0.005度</span></span><br><span class="line">    ),</span><br><span class="line">   <span class="number">4326</span></span><br><span class="line">   <span class="comment">--8307 -- SRID</span></span><br><span class="line">   );</span></span><br><span class="line"></span><br><span class="line"><span class="operator"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> user_sdo_geom_metadata</span><br><span class="line">  (table_name, column_name, diminfo, srid)</span><br><span class="line"><span class="keyword">VALUES</span></span><br><span class="line">  (<span class="string">'TLEVELLINE'</span>, <span class="comment">-- 表名</span></span><br><span class="line">   <span class="string">'GEOM'</span>, <span class="comment">-- geometry字段</span></span><br><span class="line">   SDO_DIM_ARRAY <span class="comment">-- DIMINFO 属性存储空间表中空间数据的范围和容差</span></span><br><span class="line">   (SDO_DIM_ELEMENT(<span class="string">'X'</span>, <span class="comment">-- 第一个元键名称</span></span><br><span class="line">                    -<span class="number">180</span>, <span class="comment">-- 最小X</span></span><br><span class="line">                    <span class="number">180</span>, <span class="comment">-- 最大X</span></span><br><span class="line">                    <span class="number">0.005</span>), <span class="comment">-- 容差0.005度</span></span><br><span class="line">    SDO_DIM_ELEMENT(<span class="string">'Y'</span>, <span class="comment">-- 第二个元键名称</span></span><br><span class="line">                    -<span class="number">90</span>, <span class="comment">-- 最小Y</span></span><br><span class="line">                    <span class="number">90</span>, <span class="comment">-- 最大Y</span></span><br><span class="line">                    <span class="number">0.005</span>) <span class="comment">-- 容差0.005度</span></span><br><span class="line">    ),</span><br><span class="line">   <span class="number">4326</span></span><br><span class="line">   <span class="comment">--8307 -- SRID</span></span><br><span class="line">   );</span></span><br><span class="line">   </span><br><span class="line"><span class="operator"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> user_sdo_geom_metadata</span><br><span class="line">  (table_name, column_name, diminfo, srid)</span><br><span class="line"><span class="keyword">VALUES</span></span><br><span class="line">  (<span class="string">'VGNSS'</span>, <span class="comment">-- 表名</span></span><br><span class="line">   <span class="string">'GEOM'</span>, <span class="comment">-- geometry字段</span></span><br><span class="line">   SDO_DIM_ARRAY <span class="comment">-- DIMINFO 属性存储空间表中空间数据的范围和容差</span></span><br><span class="line">   (SDO_DIM_ELEMENT(<span class="string">'X'</span>, <span class="comment">-- 第一个元键名称</span></span><br><span class="line">                    -<span class="number">180</span>, <span class="comment">-- 最小X</span></span><br><span class="line">                    <span class="number">180</span>, <span class="comment">-- 最大X</span></span><br><span class="line">                    <span class="number">0.005</span>), <span class="comment">-- 容差0.005度</span></span><br><span class="line">    SDO_DIM_ELEMENT(<span class="string">'Y'</span>, <span class="comment">-- 第二个元键名称</span></span><br><span class="line">                    -<span class="number">90</span>, <span class="comment">-- 最小Y</span></span><br><span class="line">                    <span class="number">90</span>, <span class="comment">-- 最大Y</span></span><br><span class="line">                    <span class="number">0.005</span>) <span class="comment">-- 容差0.005度</span></span><br><span class="line">    ),</span><br><span class="line">   <span class="number">4326</span></span><br><span class="line">   <span class="comment">-- 8307 -- SRID</span></span><br><span class="line">   );</span></span><br><span class="line"></span><br><span class="line"><span class="operator"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> user_sdo_geom_metadata</span><br><span class="line">  (table_name, column_name, diminfo, srid)</span><br><span class="line"><span class="keyword">VALUES</span></span><br><span class="line">  (<span class="string">'VGEOCONPOINT'</span>, <span class="comment">-- 表名</span></span><br><span class="line">   <span class="string">'GEOM'</span>, <span class="comment">-- geometry字段</span></span><br><span class="line">   SDO_DIM_ARRAY <span class="comment">-- DIMINFO 属性存储空间表中空间数据的范围和容差</span></span><br><span class="line">   (SDO_DIM_ELEMENT(<span class="string">'X'</span>, <span class="comment">-- 第一个元键名称</span></span><br><span class="line">                    -<span class="number">180</span>, <span class="comment">-- 最小X</span></span><br><span class="line">                    <span class="number">180</span>, <span class="comment">-- 最大X</span></span><br><span class="line">                    <span class="number">0.005</span>), <span class="comment">-- 容差0.005度</span></span><br><span class="line">    SDO_DIM_ELEMENT(<span class="string">'Y'</span>, <span class="comment">-- 第二个元键名称</span></span><br><span class="line">                    -<span class="number">90</span>, <span class="comment">-- 最小Y</span></span><br><span class="line">                    <span class="number">90</span>, <span class="comment">-- 最大Y</span></span><br><span class="line">                    <span class="number">0.005</span>) <span class="comment">-- 容差0.005度</span></span><br><span class="line">    ),</span><br><span class="line">   <span class="number">4326</span></span><br><span class="line">   <span class="comment">--8307 -- SRID</span></span><br><span class="line">   );</span></span><br><span class="line">   </span><br><span class="line"><span class="operator"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> user_sdo_geom_metadata</span><br><span class="line">  (table_name, column_name, diminfo, srid)</span><br><span class="line"><span class="keyword">VALUES</span></span><br><span class="line">  (<span class="string">'VLEVELLINE'</span>, <span class="comment">-- 表名</span></span><br><span class="line">   <span class="string">'GEOM'</span>, <span class="comment">-- geometry字段</span></span><br><span class="line">   SDO_DIM_ARRAY <span class="comment">-- DIMINFO 属性存储空间表中空间数据的范围和容差</span></span><br><span class="line">   (SDO_DIM_ELEMENT(<span class="string">'X'</span>, <span class="comment">-- 第一个元键名称</span></span><br><span class="line">                    -<span class="number">180</span>, <span class="comment">-- 最小X</span></span><br><span class="line">                    <span class="number">180</span>, <span class="comment">-- 最大X</span></span><br><span class="line">                    <span class="number">0.005</span>), <span class="comment">-- 容差0.005度</span></span><br><span class="line">    SDO_DIM_ELEMENT(<span class="string">'Y'</span>, <span class="comment">-- 第二个元键名称</span></span><br><span class="line">                    -<span class="number">90</span>, <span class="comment">-- 最小Y</span></span><br><span class="line">                    <span class="number">90</span>, <span class="comment">-- 最大Y</span></span><br><span class="line">                    <span class="number">0.005</span>) <span class="comment">-- 容差0.005度</span></span><br><span class="line">    ),</span><br><span class="line">   <span class="number">4326</span></span><br><span class="line">  <span class="comment">-- 8307 -- SRID</span></span><br><span class="line">   );</span></span><br><span class="line">   </span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> user_indexes <span class="keyword">where</span> table_name = <span class="string">'TGNSS'</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> user_ind_columns <span class="keyword">where</span> index_name=<span class="keyword">upper</span>(<span class="string">'&amp;IDX_TASK_GNSS_SPATIAL'</span>);</span></span><br><span class="line"><span class="operator"><span class="keyword">CREATE</span> <span class="keyword">INDEX</span> IDX_TGNSS_Spatial <span class="keyword">ON</span> TGNSS(GEOM) <span class="keyword">INDEXTYPE</span> <span class="keyword">IS</span> MDSYS.SPATIAL_INDEX;</span></span><br><span class="line"><span class="operator"><span class="keyword">CREATE</span> <span class="keyword">INDEX</span> IDX_TGEOCONPOINT_Spatial <span class="keyword">ON</span> TGEOCONPOINT(GEOM) <span class="keyword">INDEXTYPE</span> <span class="keyword">IS</span> MDSYS.SPATIAL_INDEX;</span>  </span><br><span class="line"><span class="operator"><span class="keyword">CREATE</span> <span class="keyword">INDEX</span> IDX_TLEVELLINE_Spatial <span class="keyword">ON</span> TLEVELLINE(GEOM) <span class="keyword">INDEXTYPE</span> <span class="keyword">IS</span> MDSYS.SPATIAL_INDEX;</span></span><br><span class="line"><span class="comment">--CREATE INDEX IDX_VGNSS_Spatial ON VGNSS(GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX;</span></span><br><span class="line"><span class="comment">--CREATE INDEX IDX_VGEOCONPOINT_Spatial ON VGEOCONPOINT(GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX;</span></span><br><span class="line"><span class="operator"><span class="keyword">drop</span> <span class="keyword">index</span> IDX_TGNSS_Spatial;</span></span><br><span class="line"><span class="operator"><span class="keyword">drop</span> <span class="keyword">index</span> IDX_TGEOCONPOINT_Spatial;</span></span><br><span class="line"><span class="operator"><span class="keyword">drop</span> <span class="keyword">index</span> IDX_TLEVELLINE_Spatial;</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> <span class="keyword">t</span>.*, <span class="keyword">t</span>.<span class="keyword">rowid</span> <span class="keyword">from</span> tgnss <span class="keyword">t</span>;</span></span><br><span class="line"><span class="operator"><span class="keyword">insert</span> <span class="keyword">into</span> tgnss(FID, STATION_NAME, LONGITUDE, latitude, province, point_category, station_category, geom) <span class="keyword">values</span>(</span><br><span class="line">       <span class="string">'DBD15B295DAC47059343F6A82D6DC9A2'</span>,</span><br><span class="line">       <span class="string">'曲阳'</span>,</span><br><span class="line">       <span class="number">114.69</span>,</span><br><span class="line">       <span class="number">38.63</span>,</span><br><span class="line">       <span class="string">'河北'</span>,</span><br><span class="line">       <span class="string">'改造站'</span>,</span><br><span class="line">       <span class="string">'土层'</span>,</span><br><span class="line">       MDSYS.Sdo_Geometry(</span><br><span class="line">            <span class="number">2001</span>,</span><br><span class="line">            <span class="number">4326</span>,</span><br><span class="line">            <span class="literal">null</span>,</span><br><span class="line">            MDSYS.Sdo_Elem_Info_Array(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),</span><br><span class="line">            MDSYS.Sdo_Ordinate_Array(<span class="number">114.69</span>, <span class="number">38.63</span>)</span><br><span class="line">       ));</span></span><br><span class="line">       </span><br><span class="line"><span class="operator"><span class="keyword">insert</span> <span class="keyword">into</span> tgnss(FID, STATION_NAME, LONGITUDE, latitude, province, point_category, station_category, geom) <span class="keyword">values</span>(</span><br><span class="line">       <span class="string">'E219CE03E4794AFA82BC304A6409DD89'</span>,</span><br><span class="line">       <span class="string">'延庆'</span>,</span><br><span class="line">       <span class="number">116.402222222222</span>,</span><br><span class="line">       <span class="number">40.5227777777778</span>,</span><br><span class="line">       <span class="string">'北京'</span>,</span><br><span class="line">       <span class="string">'新建站'</span>,</span><br><span class="line">       <span class="string">'基岩'</span>,</span><br><span class="line">       MDSYS.Sdo_Geometry(</span><br><span class="line">            <span class="number">2001</span>,</span><br><span class="line">            <span class="number">4326</span>,</span><br><span class="line">            <span class="literal">null</span>,</span><br><span class="line">            MDSYS.Sdo_Elem_Info_Array(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),</span><br><span class="line">            MDSYS.Sdo_Ordinate_Array(<span class="number">116.40222222222</span>, <span class="number">40.5227777777778</span>)</span><br><span class="line">       ));</span></span><br><span class="line">       </span><br><span class="line"><span class="operator"><span class="keyword">insert</span> <span class="keyword">into</span> tgeoconpoint(FID, POINT_NAME, LONGITUDE, latitude, diff_level, accu_level, province, geom, point_no) <span class="keyword">values</span>(</span><br><span class="line">       <span class="string">'C54BD8AF897A4AE1A8277E7CAD21FE5E'</span>,</span><br><span class="line">       <span class="string">'吉尔赤'</span>,</span><br><span class="line">       <span class="number">101.481</span>,</span><br><span class="line">       <span class="number">33.1204</span>,</span><br><span class="line">       <span class="string">'III'</span>,</span><br><span class="line">       <span class="string">''</span>,</span><br><span class="line">       <span class="string">'陕西局'</span>,</span><br><span class="line">       MDSYS.Sdo_Geometry(</span><br><span class="line">            <span class="number">2001</span>,</span><br><span class="line">            <span class="number">4326</span>,</span><br><span class="line">            <span class="literal">null</span>,</span><br><span class="line">            MDSYS.Sdo_Elem_Info_Array(<span class="number">1</span>,<span class="number">1</span>,<span class="number">1</span>),</span><br><span class="line">            MDSYS.Sdo_Ordinate_Array(<span class="number">114.69</span>, <span class="number">38.63</span>)</span><br><span class="line">       ),</span><br><span class="line">       <span class="number">2518</span>);</span></span><br><span class="line">       </span><br><span class="line">       </span><br><span class="line"><span class="operator"><span class="keyword">insert</span> <span class="keyword">into</span> tlevelline(FID, LINE_NUM, LINE_NAME, START_POINT, end_point, diff_level, <span class="keyword">length</span>, pointsumnum, bedrocknum, basenum, generalnum, gpsnum, proposebedrocknum, geom) <span class="keyword">values</span>(</span><br><span class="line">       <span class="string">'C9D46E977FF54BD19EF4A9B3F240CEF9'</span>,</span><br><span class="line">       <span class="number">1</span>,</span><br><span class="line">       <span class="string">'线1'</span>,</span><br><span class="line">       <span class="string">'Ⅰ刘岷４６乙'</span>,</span><br><span class="line">       <span class="string">'Ⅰ望子关基岩点'</span>,</span><br><span class="line">       <span class="string">'III'</span>,</span><br><span class="line">       <span class="string">'450'</span>,</span><br><span class="line">       <span class="number">130</span>,</span><br><span class="line">       <span class="number">0</span>,</span><br><span class="line">       <span class="number">7</span>,</span><br><span class="line">       <span class="number">122</span>,</span><br><span class="line">       <span class="number">0</span>,</span><br><span class="line">       <span class="number">1</span>,</span><br><span class="line">       MDSYS.Sdo_Geometry(</span><br><span class="line">            <span class="number">2002</span>,</span><br><span class="line">            <span class="number">4326</span>,</span><br><span class="line">            <span class="literal">null</span>,</span><br><span class="line">            MDSYS.Sdo_Elem_Info_Array(<span class="number">1</span>,<span class="number">2</span>,<span class="number">1</span>),</span><br><span class="line">            MDSYS.Sdo_Ordinate_Array(<span class="number">117.27748</span>,<span class="number">29.545202</span>, <span class="number">117.170352</span>,<span class="number">29.548818</span>, <span class="number">117.096192</span>,<span class="number">29.51263</span>)</span><br><span class="line">       ));</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> vGNSS;</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> vgeoconpoint;</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> vlevelline;</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> * <span class="keyword">from</span> TDICT_COMMON <span class="keyword">where</span> FDICTTYPE=<span class="string">'承担单位'</span> <span class="keyword">order</span> <span class="keyword">by</span> FSEQNO;</span></span><br><span class="line"><span class="operator"><span class="keyword">select</span> *</span><br><span class="line">  <span class="keyword">from</span> vgnss</span><br><span class="line"> <span class="keyword">where</span> SDO_RELATE(GEOM,</span><br><span class="line">                  sdo_geometry(<span class="string">'POLYGON((69.76880795928 12.254670943420997,69.76880795928 56.81521781842099,139.46607358428 56.815217818421004,139.46607358428002 12.254670943420997,69.76880795928 12.254670943420997))'</span>,</span><br><span class="line">                               <span class="number">4326</span>),</span><br><span class="line">                  <span class="string">'mask=ANYINTERACT'</span>) = <span class="string">'TRUE'</span></span></span><br></pre></td></tr></table></figure>
<h2 id="u53C2_u8003_u94FE_u63A5"><a href="#u53C2_u8003_u94FE_u63A5" class="headerlink" title="参考链接"></a>参考链接</h2>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/27/database/10.oracle spatial/" data-id="cijzzpvi100h31cfslq8xy4i2" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/database/">database</a></li></ul>

    </footer>
  </div>
  
</article>


  
  
    <nav id="page-nav">
      <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/15/">15</a><a class="extend next" rel="next" href="/page/2/">Next &raquo;</a>
    </nav>
  
</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/cache/">cache</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a><span class="category-list-count">13</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/">docker</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gis/">gis</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/git/">git</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/go/">go</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gradle/">gradle</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/groovy/">groovy</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/hadoop/">hadoop</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/java/">java</a><span class="category-list-count">18</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/log/">log</a><span class="category-list-count">11</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mongodb/">mongodb</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mq/">mq</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mybatis/">mybatis</a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/netty/">netty</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nginx/">nginx</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nio/">nio</a><span class="category-list-count">19</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nodejs/">nodejs</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/redis/">redis</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/rpc/">rpc</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/spring/">spring</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/tomcat/">tomcat</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/zookeeper/">zookeeper</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/杂项/">杂项</a><span class="category-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/aop/">aop</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/aspectj/">aspectj</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/classloader/">classloader</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/common-loggings/">common-loggings</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/commonjs/">commonjs</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/">docker</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dubbo/">dubbo</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fastdfs/">fastdfs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gclib/">gclib</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/geohash/">geohash</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gis/">gis</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/go/">go</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gradle/">gradle</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/groovy/">groovy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hadoop/">hadoop</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hessisan/">hessisan</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a><span class="tag-list-count">48</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javassist/">javassist</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kafka/">kafka</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log/">log</a><span class="tag-list-count">11</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log4j/">log4j</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/logback/">logback</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/map/">map</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memecached/">memecached</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mina/">mina</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mongodb/">mongodb</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mq/">mq</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mqtt/">mqtt</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mybatis/">mybatis</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netty/">netty</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/">nginx</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nio/">nio</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/">nodejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/postgresql/">postgresql</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/proxy/">proxy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/push/">push</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rabbitmq/">rabbitmq</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/">redis</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rpc/">rpc</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sitemesh/">sitemesh</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sld/">sld</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/slf4j/">slf4j</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/socket/">socket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spatialite-for-android/">spatialite for android</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spi/">spi</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spring/">spring</a><span class="tag-list-count">13</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tomcat/">tomcat</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/transaction/">transaction</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/web/">web</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xSocket/">xSocket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zbus/">zbus</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zookeeper/">zookeeper</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/数据结构/">数据结构</a><span class="tag-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/aop/" style="font-size: 15.38px;">aop</a> <a href="/tags/aspectj/" style="font-size: 11.54px;">aspectj</a> <a href="/tags/cache/" style="font-size: 11.54px;">cache</a> <a href="/tags/classloader/" style="font-size: 10px;">classloader</a> <a href="/tags/common-loggings/" style="font-size: 10px;">common-loggings</a> <a href="/tags/commonjs/" style="font-size: 12.31px;">commonjs</a> <a href="/tags/database/" style="font-size: 16.92px;">database</a> <a href="/tags/docker/" style="font-size: 13.85px;">docker</a> <a href="/tags/dubbo/" style="font-size: 10px;">dubbo</a> <a href="/tags/fastdfs/" style="font-size: 10px;">fastdfs</a> <a href="/tags/gclib/" style="font-size: 10.77px;">gclib</a> <a href="/tags/geohash/" style="font-size: 10px;">geohash</a> <a href="/tags/gis/" style="font-size: 10px;">gis</a> <a href="/tags/git/" style="font-size: 10.77px;">git</a> <a href="/tags/go/" style="font-size: 10px;">go</a> <a href="/tags/gradle/" style="font-size: 10px;">gradle</a> <a href="/tags/groovy/" style="font-size: 10px;">groovy</a> <a href="/tags/hadoop/" style="font-size: 10px;">hadoop</a> <a href="/tags/hessisan/" style="font-size: 11.54px;">hessisan</a> <a href="/tags/java/" style="font-size: 20px;">java</a> <a href="/tags/javassist/" style="font-size: 10px;">javassist</a> <a href="/tags/kafka/" style="font-size: 11.54px;">kafka</a> <a href="/tags/linux/" style="font-size: 12.31px;">linux</a> <a href="/tags/log/" style="font-size: 17.69px;">log</a> <a href="/tags/log4j/" style="font-size: 12.31px;">log4j</a> <a href="/tags/logback/" style="font-size: 13.08px;">logback</a> <a href="/tags/map/" style="font-size: 10px;">map</a> <a href="/tags/memecached/" style="font-size: 10.77px;">memecached</a> <a href="/tags/mina/" style="font-size: 13.08px;">mina</a> <a href="/tags/mongodb/" style="font-size: 19.23px;">mongodb</a> <a href="/tags/mq/" style="font-size: 13.85px;">mq</a> <a href="/tags/mqtt/" style="font-size: 10.77px;">mqtt</a> <a href="/tags/mybatis/" style="font-size: 16.15px;">mybatis</a> <a href="/tags/netty/" style="font-size: 10px;">netty</a> <a href="/tags/nginx/" style="font-size: 11.54px;">nginx</a> <a href="/tags/nio/" style="font-size: 13.08px;">nio</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/postgresql/" style="font-size: 10.77px;">postgresql</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/proxy/" style="font-size: 10px;">proxy</a> <a href="/tags/push/" style="font-size: 10px;">push</a> <a href="/tags/rabbitmq/" style="font-size: 11.54px;">rabbitmq</a> <a href="/tags/redis/" style="font-size: 13.85px;">redis</a> <a href="/tags/rpc/" style="font-size: 19.23px;">rpc</a> <a href="/tags/sitemesh/" style="font-size: 10px;">sitemesh</a> <a href="/tags/sld/" style="font-size: 10px;">sld</a> <a href="/tags/slf4j/" style="font-size: 10px;">slf4j</a> <a href="/tags/socket/" style="font-size: 14.62px;">socket</a> <a href="/tags/spatialite-for-android/" style="font-size: 10px;">spatialite for android</a> <a href="/tags/spi/" style="font-size: 10px;">spi</a> <a href="/tags/spring/" style="font-size: 18.46px;">spring</a> <a href="/tags/tomcat/" style="font-size: 10.77px;">tomcat</a> <a href="/tags/transaction/" style="font-size: 10px;">transaction</a> <a href="/tags/web/" style="font-size: 10px;">web</a> <a href="/tags/xSocket/" style="font-size: 14.62px;">xSocket</a> <a href="/tags/zbus/" style="font-size: 10px;">zbus</a> <a href="/tags/zookeeper/" style="font-size: 10.77px;">zookeeper</a> <a href="/tags/数据结构/" style="font-size: 10.77px;">数据结构</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a><span class="archive-list-count">67</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">December 2015</a><span class="archive-list-count">81</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a><span class="archive-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/01/30/资料/">(no title)</a>
          </li>
        
          <li>
            <a href="/2016/01/30/java/13.Classloader系列一/">ClassLoader系列一</a>
          </li>
        
          <li>
            <a href="/2016/01/29/hadoop/1.hadoop系列之源码编译/">hadoop系列一之源码编译</a>
          </li>
        
          <li>
            <a href="/2016/01/29/go/1.GO系列之入门/">Go系列一之入门</a>
          </li>
        
          <li>
            <a href="/2016/01/28/tomcat/2.tomcat性能优化/">tomcat性能优化</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="http://libs.baidu.com/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">
  <script src="/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>


<script src="/js/script.js" type="text/javascript"></script>

  </div>
</body>
</html>